// declare new variables for each new div that you add, and link to the div by ID
// var region_div = document.getElementById("region_div");
var doc = null;
function ajax() {
	// Make a new XMLHttp object

    if (window.XMLHttpRequest) {
        try {
            doc = new XMLHttpRequest();
        } catch(e)  {}
    } else if (window.ActiveXObject) {
        try {
            doc = new ActiveXObject('Msxml2.XMLHTTP');
        } catch(e)  {
          try {
              doc = new ActiveXObject('Microsoft.XMLHTTP');
          } catch(e)  {}
        }
    }
}

	
var All_product=0;
var All_running_list=0;
var All_running=0;

function Valid_bsmusername(login){
		ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	   if (doc){
	       doc.open("GET", "check.php?section=username&login="+login, false); 
	       doc.send(null);
	      return  doc.responseText;
	    }
}

function Edit_Valid_username(login,current_login){
    	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	   if (doc){
	       doc.open("GET", "check.php?section=edit_username&login="+login"and current_login="+current_login, false); 
	       doc.send(null);
		  
	      return  doc.responseText;
	    }
}

//////////////////////////////////////////////////////////
function Update_Bid_Detail(Runngin_list,product_id)
{		
		var doc=null;
	 	 if (window.XMLHttpRequest) {
        try {
            doc = new XMLHttpRequest();
        } catch(e)  {}
    } else if (window.ActiveXObject) {
        try {
            doc = new ActiveXObject('Msxml2.XMLHTTP');
        } catch(e)  {
          try {
              doc = new ActiveXObject('Microsoft.XMLHTTP');
          } catch(e)  {}
        }
    }
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	  

	   doc.open('GET', "./location.php?section=update_bid&Runngin_list="+Runngin_list, true);
       doc.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 
		
       doc.onreadystatechange = function()
	   	{ 
	 	  if (doc.readyState == 4)
		  	{
				
	           if (doc.status == 200)
				{
						
				if(product_id!='')
					Update_bid_table(product_id);
				//alert(doc.responseText);	
				if(doc.responseText!=0)
				{
				
				var arraylist2=doc.responseText.split("=#=");
				var All_String="";
				var arraylist1=arraylist2[0].split("|@|");
				var arraylist4=Runngin_list.split(",");
				var Bid_array =arraylist2[1].split(",");
				
				for(l=0;l<arraylist1.length;l++)
				{	 
				
				var arraylist=arraylist1[l].split("**");
				var pro_id =(parseInt(arraylist[0]));

				var bid_counter_array =arraylist4[l].split("|@|");
				var bid_counter =(parseInt(bid_counter_array[1]));
			
				var new_bid_counter_array =Bid_array[l].split("|@|");
				var new_bid_counter =(parseInt(new_bid_counter_array[1]));
					
				if(bid_counter!=new_bid_counter && All_running_list!='')
				{
					Extend_timer[pro_id]=arraylist[5];
					document.getElementById('price_index_div_'+pro_id).style.color = '#ffffff';
					document.getElementById('price_index_div_'+pro_id).style.backgroundColor = '#fa0000';
					document.getElementById('price_index_div_'+pro_id).innerHTML = arraylist[1];	
					document.getElementById('winner_index_div_'+pro_id).innerHTML = arraylist[3];
//					alert('updatecoin nih');
					updatecoin();
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.backgroundColor = ""', 1000);
					setTimeout('document.getElementById("price_index_div_'+pro_id+'").style.color = "#fa0000"', 1000);
				}
				}

				All_running_list=arraylist2[1];
				}  
			}
			}
	    };
	
	if(All_running_list!=0)
		Runngin_list=All_running_list;
		
		
		 setTimeout('Update_Bid_Detail("'+Runngin_list+'","'+product_id+'")', 3000); 
        doc.send(null);
}


function Get_Bidder_list(Runngin_list,Pagename,product_id){
		
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!
	 
	 var doc=null;
	 	 if (window.XMLHttpRequest) {
        try {
            doc = new XMLHttpRequest();
        } catch(e)  {}
    } else if (window.ActiveXObject) {
        try {
            doc = new ActiveXObject('Msxml2.XMLHTTP');
        } catch(e)  {
          try {
              doc = new ActiveXObject('Microsoft.XMLHTTP');
          } catch(e)  {}
        }
    }
	
	
		
		 Auto_bidbutler();		
	  doc.open('GET', "./location.php?section=max_bidder&Pagename="+Pagename+"&Runngin_list="+Runngin_list+"&product_id="+product_id, true);
        doc.setRequestHeader('Content-Type','application/x-www-form-urlencoded');  
  
   doc.onreadystatechange = function() { 
		
	  if (doc.readyState == 4) { 
	
           if (doc.status == 200) { 
			if(doc.responseText!='')
			{
			var arraylist2=doc.responseText.split("=#=");
			var All_String="";
			var All_Price="";
			var arraylist1=arraylist2[0].split("|@|");

		for(var l=0;l<arraylist1.length;l++)
			{	
				var arraylist=arraylist1[l].split("**");
				var pro_id =(parseInt(arraylist[0]));

				if(arraylist[2]!="NN" && arraylist[1]!="NP")
					{	
					if(arraylist[1]=="P")
						{
						if(pro_id==product_id)
						{
						document.getElementById('bid_btn_'+pro_id).innerHTML = "<img src='images/mainsite/paused_big_btn.jpg' border='0' />";
						document.getElementById('counter_index_div_'+pro_id).innerHTML = "<b>-- : -- : --</b>";
						}
						else
						{
						document.getElementById('bid_btn_'+pro_id).innerHTML = "<img src='images/mainsite/pause_btn.gif' border='0' />";
						document.getElementById('counter_index_div_'+pro_id).innerHTML = "<b>PAUSE</b>";
						}
						}
					else
						{
							
						var diff =parseInt(arraylist[1]);
						Extend_timer[pro_id]=diff;
						if(diff>0)
						{
							if(l==0)
								All_String=pro_id+"**E**"+arraylist[5];
							else
								All_String=All_String+"|@|"+pro_id+"**E**"+arraylist[5];
							document.getElementById('bid_btn_'+pro_id).innerHTML = arraylist[2];
							if(pro_id==product_id)
							document.getElementById('flashing_index_div_'+pro_id).innerHTML = arraylist[4];
						}
    					else
						{
						if(arraylist[3]=='S')
							{
						if(pro_id==product_id)		
							document.getElementById('bid_btn_'+pro_id).innerHTML = "<img src='images/mainsite/sold_big_btn.jpg' border='0' />";
						else
							document.getElementById('bid_btn_'+pro_id).innerHTML = "<img src='images/mainsite/sold_btn.jpg' border='0' />";
							document.getElementById('counter_index_div_'+pro_id).innerHTML = "<font color='red'><b>TERJUAL</b></font>";
							Congratulation_auction(pro_id);

							}
						else
							{
						if(pro_id==product_id)				
							document.getElementById('bid_btn_'+pro_id).innerHTML = "";
						else
							document.getElementById('bid_btn_'+pro_id).innerHTML = "<a href='index.php?show=product&id="+pro_id+"><img src='images/mainsite/info_btn.gif' border='0'></a>";
//							document.getElementById('counter_index_div_'+pro_id).innerHTML = "<font color='red'><b>CHECKING</b></font>";
							document.getElementById('counter_index_div_'+pro_id).innerHTML = "";
							Expire_extend_bid(pro_id,product_id); 
							}
						}
					}
				}
			else if(arraylist[1]=="NP")
				{
					if(pro_id==product_id)	
					{
					document.getElementById('bid_btn_'+pro_id).innerHTML = "<img src='images/mainsite/paused_big_btn.jpg' border='0'/>";
					document.getElementById('counter_index_div_'+pro_id).innerHTML = "<b>-- : -- : --</b>";
					}
					else
					{
					document.getElementById('bid_btn_'+pro_id).innerHTML = "<img src='images/mainsite/pause_btn.gif' border='0'/>";
					document.getElementById('counter_index_div_'+pro_id).innerHTML = "<b>PAUSE</b>";
					}
				}
			else if(arraylist[2]=="NN")
				{
					var diff =parseInt(arraylist[1]);
					Extend_timer[pro_id]=diff;
						if(l==0)
								All_String=pro_id+"**N";
							else
								All_String=All_String+"|@|"+pro_id+"**N";

					document.getElementById('bid_btn_'+pro_id).innerHTML = arraylist[3];
				}
				
				if(pro_id==product_id)
				{
					var arraylist3=arraylist2[2].split("*@*");

					if(arraylist3[2]=="L")
					{
				  	document.getElementById('place_bid_div_'+pro_id).innerHTML = arraylist3[4];
//					if(arraylist3[3]!="I" && arraylist2[3]=='Y')
					if(arraylist3[3]!="I")
//						alert(arraylist2[3]);
						document.getElementById("bid_from").value = arraylist3[3];
					
					if(arraylist3[5]!="R")
					Update_bid_table(pro_id);
					}
					else
					{
						if(arraylist3[2]!="R")
							Update_bid_table(pro_id);	
					}

//					document.getElementById('winner_index_div_'+pro_id).innerHTML = arraylist3[0];
//					document.getElementById('price_index_div_'+pro_id).innerHTML = arraylist3[0];
					document.getElementById('price_index1_div_'+pro_id).innerHTML = arraylist3[0];
					document.getElementById('price_save_div_'+pro_id).innerHTML = arraylist3[1];


				}
			
			} 

				if(All_String!="")
					{
					All_product=arraylist2[1];
					Update_bidder_timer(All_String,1,Pagename,arraylist2[1],product_id);
					}
		}
		
               
            }
	  }
	  
		        };
	
	
	  if(All_product!=0)
	  	Runngin_list=All_product;
	  
	 
	  setTimeout('Get_Bidder_list("'+Runngin_list+'","'+Pagename+'","'+product_id+'")', 10000);
	  
	   doc.send(null);
		
	

 }
 


function  Update_bidder_timer(All_String,Timer,Pagename,Runngin_list,product_id){
	var arraylist1=All_String.split("|@|");	
	for(l=0;l<arraylist1.length;l++)
	{	
		if(arraylist1[l]!="")
		{
			var arraylist=arraylist1[l].split("**");

   			var pro_id =(parseInt(arraylist[0]));
			var diff=Extend_timer[pro_id];	
			var timer_color=arraylist[2];
		
			diff=parseInt((diff-Timer));
			if(diff>0)
			{
				if(arraylist[1]=="E")
				{
					if(timer_color!='')
					document.getElementById('counter_index_div_'+pro_id).innerHTML = "<font color='"+timer_color+"'>" + calc_counter_from_time_short(diff) + "</font>";
					else
					document.getElementById('counter_index_div_'+pro_id).innerHTML = "<font color='red'>" + calc_counter_from_time_short(diff) + "</font>";
				}
				else if(arraylist[1]=="N")
					document.getElementById('counter_index_div_'+pro_id).innerHTML = '' + calc_counter_from_time(diff);

			}
			else
			{
						Expire_home_bid(pro_id);
				if(arraylist[1]=="E")
				{
//					if(pro_id==product_id)
//					{
//						document.getElementById('bid_btn_'+pro_id).innerHTML = "<img src='images/mainsite/sold_big_btn.jpg' border='0' />";
//						document.getElementById('bid_btn_'+pro_id).innerHTML = "";
//						Congratulation_auction(pro_id);
//					}
//					else
//						document.getElementById('bid_btn_'+pro_id).innerHTML = "<img src='images/mainsite/sold_btn.jpg' border='0' />";
//						document.getElementById('bid_btn_'+pro_id).innerHTML = "";
//
// YANG SERING DIPAKE					
//					document.getElementById('counter_index_div_'+pro_id).innerHTML = "<font color='red'><b>CHECKING</b></font>";
					document.getElementById('counter_index_div_'+pro_id).innerHTML = "";
					Expire_extend_bid(pro_id,product_id);
				}
				else 
				{
					if(arraylist[1]=="N")
						Expire_home_bid(pro_id);
					else
						{
//				alert(arraylist[1]);
						if(pro_id==product_id)
							document.getElementById('bid_btn_'+pro_id).innerHTML = "";
						else
							document.getElementById('bid_btn_'+pro_id).innerHTML = "<a href='index.php?show=product&id="+pro_id+"><img src='images/mainsite/info_btn.gif' border='0'></a>";
//						document.getElementById('counter_index_div_'+pro_id).innerHTML = "<font color='red'><b>CHECKING</b></font>";
						document.getElementById('counter_index_div_'+pro_id).innerHTML = "";
						}
				}
			}
		}
	}
	Timer=Timer+1;	
	Timer=parseInt(Timer);
	if(Timer<=10)
		setTimeout('Update_bidder_timer("'+All_String+'",'+Timer+',"'+Pagename+'","'+Runngin_list+'","'+product_id+'")', 1000);
}

function CheckAvail(id_region){

		var avail=document.getElementById(id_region).value;
		
		ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       //destination.innerHTML = "Loading data...";	
	       doc.open("GET", "location1.php?section=tutoring&avail="+avail, false);
	       doc.send(null);
	    	// Write the response to the div
			
			//document.getElementById('user_available').innerHTML = doc.responseText;
			//alert(arraylist[0]);
			if(doc.responseText==1) 
				{
				alert(document.getElementById('username_already_exist').innerHTML+"\n");
				return false;
				}
			else if(doc.responseText==2)
			 {
				alert(document.getElementById('this_username_available').innerHTML+"\n");
				return false; 
			 }
			else if(doc.responseText==3)
			 {
				alert(document.getElementById('please_enter_username').innerHTML+"\n");
				return false; 
			 } 
			else
			return true;
			 
		}	
	
	}
function CheckEmail(id_region){

		var emailadd=document.getElementById(id_region).value;
		
		ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       //destination.innerHTML = "Loading data...";	
	       doc.open("GET", "location1.php?section=availmail&emailadd="+emailadd, false);
	       doc.send(null);
	    	// Write the response to the div
			
			//document.getElementById('email_available').innerHTML = doc.responseText;
			
			if(doc.responseText==1) 
				{
				alert(document.getElementById('email_already_exist').innerHTML+"\n");
				return false;
				}
		else if(doc.responseText==2)
			 {
				alert(document.getElementById('this_email_available').innerHTML+"\n");
				return false; 
			 }
			else if(doc.responseText==3)
			 {
				alert(document.getElementById('please_enter_email').innerHTML+"\n");
				return false; 
			 } 
			else
			return true;
	    }	
	
	}	


function Valid_mobile(tel){
		ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	   if (doc){
	       doc.open("GET", "./location1.php?section=mobile&tel="+tel, false); 
	       doc.send(null);
	      return  doc.responseText;
	    }
}

function Edit_Valid_mobile(tel){
    	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	   if (doc){
	       doc.open("GET", "./location1.php?section=edit_mobile&tel="+tel, false); 
	       doc.send(null);
		  
	      return  doc.responseText;
	    }
}

function Valid_ktp(ktp){
    	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	   if (doc){
	       doc.open("GET", "./location1.php?section=edit_ktp&ktp="+ktp, false); 
	       doc.send(null);
	      return  doc.responseText;
	    }
}

function Edit_Valid_ktp(ktp){
    	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	   if (doc){
	       doc.open("GET", "./location1.php?section=edit_ktp&ktp="+ktp, false); 
	       doc.send(null);
		  
	      return  doc.responseText;
	    }
        }




function Valid_email(email){
		
    	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	   if (doc){
	       doc.open("GET", "./location1.php?section=email&email="+email, false);   
	       doc.send(null);
	      return  doc.responseText;
	    }
}

function Edit_Valid_email(email){
		
    	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	   if (doc){
	       doc.open("GET", "./location1.php?section=edit_email&email="+email, false);   
	       doc.send(null);
	      return  doc.responseText;
	    }
}


function Admin_Valid_username(login){
		ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	   if (doc){
	       doc.open("GET", "./location1.php?section=admin_username&login="+login, false); 
	       doc.send(null);
	      return  doc.responseText;
	    }
}


function Admin_Valid_mobile(tel){
		ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	   if (doc){
	       doc.open("GET", "./location1.php?section=admin_mobile&mobile="+mobile, false); 
	       doc.send(null);
	      return  doc.responseText;
	    }
}

function Admin_Edit_Valid_mobile(mobile,edit_id){
    	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	   if (doc){
	       doc.open("GET", "./location1.php?section=admin_edit_mobile&mobile="+mobile+"&user_id="+edit_id, false); 
	       doc.send(null);
		  
	      return  doc.responseText;
	    }
}

function Admin_Edit_Valid_username(login,edit_id){
    	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	   if (doc){
	       doc.open("GET", "./location1.php?section=admin_edit_username&login="+login+"&user_id="+edit_id, false); 
	       doc.send(null);

	      return  doc.responseText;
	    }
}



function Admin_Valid_email(email){
		
    	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	   if (doc){
	       doc.open("GET", "./location1.php?section=admin_email&email="+email, false);   
	       doc.send(null);
	      return  doc.responseText;
	    }
}

function Admim_Edit_Valid_email(email,edit_id){
		
    	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	   if (doc){
	       doc.open("GET", "./location1.php?section=admin_edit_email&email="+email+"&user_id="+edit_id, false);   
	       doc.send(null);
	      return  doc.responseText;
	    }
}

function bid_list(item_id,table_type)
{
	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	   if (doc){
	       doc.open("GET", "./location.php?section=bid_list_table&item_id="+item_id+"&table_type="+table_type, false);   
	       doc.send(null);

			document.getElementById('bidlist_table_div').innerHTML = doc.responseText;

			if(table_type=='B')
				Update_bid_table(item_id);
	    }
}

function bidbutler_list(item_id,table_type)
{
	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	   if (doc){
	       doc.open("GET", "./location.php?section=book_bidbutler_table&item_id="+item_id+"&table_type="+table_type, false);   
	       doc.send(null);

			document.getElementById('book_bidbutler_table_div').innerHTML = doc.responseText;

	    }
}


	
function get_info_drop_dowm(promotion_id){

		ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       doc.open("GET", "./location1.php?section=promotion&promotion_id=" + promotion_id, false);
	       doc.send(null);
	    	// Write the response to the div	    	
		   document.getElementById('info_div').innerHTML = doc.responseText;
	    }	
	}
	

	
	
function Auto_bid_expire()
	{
		ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	   if (doc){
	       doc.open("GET", "./location1.php?section=autobid_expire", false);   
	       doc.send(null);
			}
	}

function Start_Bid() {
    
	
	 var doc=null;
	 	 if (window.XMLHttpRequest) {
        try {
            doc = new XMLHttpRequest();
        } catch(e)  {}
    } else if (window.ActiveXObject) {
        try {
            doc = new ActiveXObject('Msxml2.XMLHTTP');
        } catch(e)  {
          try {
              doc = new ActiveXObject('Microsoft.XMLHTTP');
          } catch(e)  {}
        }
    }
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	  
	   doc.open('GET', "./location.php?section=start_bid", true);
        doc.setRequestHeader('Content-Type','application/x-www-form-urlencoded');        
       doc.onreadystatechange = function()
	   	{ 
	 	  if (doc.readyState == 4)
		  	{
	           if (doc.status == 200)
				   setTimeout('Start_Bid();',10000);
			   else
			   		setTimeout('Start_Bid();',10000);
			}
		}
		doc.send(null);
}

function Show_advert()
	{
		ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	   if (doc){
	       doc.open("GET", "./location.php?Response=show_advert", false);   
	       doc.send(null);
		    document.getElementById('advert_div').innerHTML = doc.responseText;
			}
		
	}	


function Update_bid_table(product_id){
		ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       doc.open("GET", "./location.php?section=update_bid_table&product_id="+product_id, false);
	       doc.send(null);
	    	// Write the response to the div
		   document.getElementById('bid_table_div1').innerHTML = doc.responseText;
		}
	}
	

function Update_bid_auction()
	{
		
		 var doc=null;
	 	 if (window.XMLHttpRequest) {
        try {
            doc = new XMLHttpRequest();
        } catch(e)  {}
    } else if (window.ActiveXObject) {
        try {
            doc = new ActiveXObject('Msxml2.XMLHTTP');
        } catch(e)  {
          try {
              doc = new ActiveXObject('Microsoft.XMLHTTP');
          } catch(e)  {}
        }
    }
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	  
	   doc.open('GET', "./location.php?section=update_auction", true);
        doc.setRequestHeader('Content-Type', 
            'application/x-www-form-urlencoded');        
       doc.onreadystatechange = function()
	   	{ 
	 	  if (doc.readyState == 4)
		  	{
	           if (doc.status != 200)
		  			setTimeout('Update_bid_auction();',10000);
			}
		}
		doc.send(null);
	}



function Update_session()
	{
		ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	   if (doc){
	       doc.open("GET", "./location1.php?section=update_session", false);   
	       doc.send(null);
			}
	}

function Auto_bidbutler() {
    ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
		if (doc){
	       doc.open("GET", "./location.php?section=auto_bidbutler", false);
 			doc.send(null);
			}
			
		
}


function Expire_home_bid(pro_id) {
    ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       doc.open("GET", "./location.php?section=expire_bid&pro_id=" + pro_id, false);
 			doc.send(null);
			
			}
}	

function Expire_extend_bid(pro_id,product_id) {
  			
  var doc=null;
	 	 if (window.XMLHttpRequest) {
        try {
            doc = new XMLHttpRequest();
        } catch(e)  {}
    } else if (window.ActiveXObject) {
        try {
            doc = new ActiveXObject('Msxml2.XMLHTTP');
        } catch(e)  {
          try {
              doc = new ActiveXObject('Microsoft.XMLHTTP');
          } catch(e)  {}
        }
    }
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	  
	   doc.open('GET', "./location.php?section=expire_extend&pro_id="+pro_id, true);
        doc.setRequestHeader('Content-Type', 
            'application/x-www-form-urlencoded');        
       doc.onreadystatechange = function()
	   	{ 
	 	  if (doc.readyState == 4)
		  	{
	           if (doc.status == 200)
				{   
				 
	      			if(doc.responseText!='')
						{
						var pro_id =(parseInt(doc.responseText));
					document.getElementById('counter_index_div_'+pro_id).innerHTML = "<font color='red'><b>TERJUAL</b></font>" ;
					if(pro_id==product_id)				
				document.getElementById('bid_btn_'+pro_id).innerHTML = "<img src='images/mainsite/sold_big_btn.jpg' border='0' />";
				else
					document.getElementById('bid_btn_'+pro_id).innerHTML = "<img src='images/mainsite/sold_btn.jpg' border='0' />";
				setTimeout('Update_bid_auction()', 5000);

					if(pro_id==product_id)		
						Congratulation_auction(pro_id); 
				}
			}
			else
				{
					setTimeout('Expire_extend_bid('+pro_id+','+product_id+');',10000);
				}
			}
		}
			doc.send(null);
}	

function Start_auction() {
    ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       doc.open("GET", "./location1.php?section=start_auction", false);
		   	doc.send(null);
			}
}


function add_to_watchlist(item_id){

	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       doc.open("GET", "./location1.php?section=add_to_watchlist&item_id=" + item_id, false);
		   	doc.send(null);
			
			if(doc.responseText==1)
				alert("This product to be add in your watchlist successfully.");
			}
}
	
	

	
	function calc_counter_from_time(diff) 
{

  if (diff > 0) {
	days=Math.floor(diff / (3600*24))
		  
    hours=Math.floor((diff / 3600)-(days*24))
				
    minutes=Math.floor((diff / 3600 - hours -(days*24)) * 60)
	
    seconds=Math.round((((diff / 3600 - hours-(days*24)) * 60) - minutes) * 60)
  } else {
	days=0;
    hours = 0;
    minutes = 0;
    seconds = 0;
  }

  if (seconds == 60) {
    seconds = 0;
  }

  if (minutes < 10) {
    if (minutes < 0) {
      minutes = 0;
    }
    minutes = '0' + minutes;
  }
  if (seconds < 10) {
    if (seconds < 0) {
      seconds = 0;
    }
    seconds = '0' + seconds;
  }
  if (hours < 10) {
    if (hours < 0) {
      hours = 0;
    }
    hours = '0' + hours;
  }
  

  return hours + " : " + minutes + " : " + seconds;
}


function calc_counter_from_time_short(diff) {

  if (diff > 0) {
    hours=Math.floor(diff / 3600)

    minutes=Math.floor((diff / 3600 - hours) * 60)

    seconds=Math.round((((diff / 3600 - hours) * 60) - minutes) * 60)
  } else {
    hours = 0;
    minutes = 0;
    seconds = 0;
  }

  if (seconds == 60) {
    seconds = 0;
  }

  if (minutes < 10) {
    if (minutes < 0) {
      minutes = 0;
    }
    minutes = '0' + minutes;
  }
  if (seconds < 10) {
    if (seconds < 0) {
      seconds = 0;
    }
    seconds = '0' + seconds;
  }
  if (hours < 10) {
    if (hours < 0) {
      hours = 0;
    }
    hours = '0' + hours;
  }

  return minutes + " : " + seconds;
}

function updatecoin() {
    	
		ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       doc.open("GET", "./location.php?section=update_coin", false);
 			doc.send(null);

				
			if(parseInt(doc.responseText)!=99999)
//				document.location="index.php?show=login";
//			else
				{
			document.getElementById('div_blance').innerHTML = doc.responseText;
				}
			}
}

function Add_bid(pro_id) {
    	
		ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       doc.open("GET", "./location.php?section=add_bid&pro_id="+pro_id, false);
 			doc.send(null);
				
			if(parseInt(doc.responseText)==99999)
				document.location="index.php?show=login";
			else
				{
				var mainarraylist=doc.responseText.split("**");
				if(mainarraylist.length>1)
					{
					document.getElementById('price_index_div_'+parseInt(pro_id)).innerHTML = mainarraylist[0];
					document.getElementById('winner_index_div_'+parseInt(pro_id)).innerHTML = mainarraylist[1];
					document.getElementById('div_blance').innerHTML = mainarraylist[3];
					
					}
				else
					alert(doc.responseText);
				}
			}

}

function check_bid(pro_id,Ptype,Pagename) {
    	
		ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       doc.open("GET", "./location.php?section=check_bid&pro_id="+pro_id+"&Pagename="+Pagename+"&Ptype="+Ptype, false);
 			doc.send(null);
				
			if(parseInt(doc.responseText)==99999)
				document.location="index.php?show=login";
			else
				{
				var mainarraylist=doc.responseText.split("***");	
				if(mainarraylist[0]==1)
					{
					window.open(mainarraylist[1],'subwindow','toolbar=no, location=no, directories=no, status=no, top=200, left=350, scrollbars=yes, menubar=no, resizable=no, maximize=no, width=300, height=160');
			
					}
				else
					alert(doc.responseText);
				}
			}
			
}


function showdisplayasisten(item_id){

	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       doc.open("GET", "./location1.php?section=show_detail_asisten&item_id=" + item_id, false);
		   	doc.send(null);
//			alert(doc.responseText);
			document.getElementById('auction_detail_'+parseInt(item_id)).innerHTML = doc.responseText;
					
			}
}

function showdisplay(item_id){

	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       doc.open("GET", "./location1.php?section=show_detail&item_id=" + item_id, false);
		   	doc.send(null);
			//alert(doc.responseText);
			document.getElementById('auction_detail_'+parseInt(item_id)).innerHTML = doc.responseText;
					
			}
}

function hidedisplay(item_id){

document.getElementById('auction_detail_'+parseInt(item_id)).innerHTML = '';

}

function Congratulation_auction(item_id)
{
	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       doc.open("GET", "./location.php?section=congratulation_auction&item_id="+item_id, false);
 			doc.send(null);

			document.getElementById('congratulation_auction_div_'+parseInt(item_id)).innerHTML = doc.responseText;
		}
	
}

function showzoomdisplay(item_id){

	ajax();
		// Load the result from the response page
		// ** As far a I know firefox will only load a document on the SAME domain!!	
	    if (doc){
	       doc.open("GET", "./location1.php?section=showzoomdisplay&item_id=" + item_id, false);
		   	doc.send(null);
			//alert(doc.responseText);
			document.getElementById('zoom_img_'+parseInt(item_id)).innerHTML = doc.responseText;
					
			}
}

function hidezoomdisplay(item_id){

document.getElementById('zoom_img_'+parseInt(item_id)).innerHTML = '';

}






